package com.sqx.modules.resumes.controller;

import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.resumes.entity.Resumes;
import com.sqx.modules.resumes.service.IResumesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.sqx.common.utils.Result;

/**
 * @author wuchang
 * @since 2023-07-24
 */
@RestController
@RequestMapping("/app/resumes/")
@Api(value = "用户端-我的简历", tags = {"用户端-我的简历"})
public class AppResumesController {
    @Autowired
    private IResumesService iResumesService;

    @Login
    @ApiOperation("新增简历")
    @PostMapping(value = "saveResumes")
    public Result saveResumes(@RequestAttribute("userId") Long userId, Resumes resumes) {
        resumes.setUserId(userId);
        return iResumesService.saveResumes(resumes);
    }

    @Login
    @ApiOperation("获取我的简历列表")
    @GetMapping(value = "getMyResumesList")
    public Result getMyResumesList(@RequestAttribute("userId") Long userId, Integer page, Integer limit, Resumes resumes) {
        resumes.setUserId(userId);
        return Result.success().put("data", iResumesService.getMyResumesList(page, limit, resumes));
    }
    @ApiOperation("获取我的简详情")
    @GetMapping(value = "getResumes")
    public Result getResumes(Long resumesId){
        return Result.success().put("data", iResumesService.getById(resumesId));
    }

    @Login
    @ApiOperation("删除简历")
    @PostMapping(value = "deleteResumes")
    public Result deleteResumes(@RequestAttribute("userId") Long userId, Long resumesId) {
        return iResumesService.deleteResumes(userId, resumesId);
    }

    @ApiOperation("根据求职信息获取简历")
    @GetMapping(value = "getResumesInfo")
    public Result getResumesInfo(Long postPushId) {
        return Result.success().put("data", iResumesService.getResumesInfo(postPushId));
    }
}
